package Offer.offer2018;

import java.util.Stack;

/**
 * Created by 雷文康 on 2018/3/4.
 */
public class Test21 {
    Stack<Integer> stack1 = new Stack<>();
    Stack<Integer> stack2= new Stack<>();
    public void push(int value) {
        stack1.push(value);
        if (stack2.isEmpty()) {
            stack2.push(value);
        } else {
            if (stack2.peek() < value) {
                stack2.push(stack2.peek());
            } else {
                stack2.push(value);
            }
        }
    }

    public int pop(){
        if (stack1.isEmpty()) {
            return -1;
        } else {
            stack2.pop();
            return stack1.pop();
        }
    }
    public int min() {
        return stack2.peek();
    }
}
